package com.denlaku.longan.sql;

import java.util.ArrayList;
import java.util.List;

import com.denlaku.longan.vo.DataSet;
import lombok.Getter;

/**
 * @author tianx
 */
@Getter
public class SqlInfo {

	private final List<SelectItem> selectItems = new ArrayList<>();
	private final List<WhereItem> whereItems = new ArrayList<>();
	private final List<GroupByItem> groupByItems = new ArrayList<>();
	private final List<HavingItem> havingItems = new ArrayList<>();
	private final List<OrderByItem> orderByItems = new ArrayList<>();
	private String tableName;
	private Limit limit;

	private DataSet dataSet;

    public void addSelectItem(SelectItem item) {
		this.selectItems.add(item);
	}

    public void setTableName(String tableName) {
		this.tableName = tableName;
	}

    public void addWhereItem(WhereItem item) {
		if (item == null) {
			return;
		}
		this.whereItems.add(item);
	}

    public void addGroupByItem(GroupByItem item) {
		if (item == null) {
			return;
		}
		this.groupByItems.add(item);
	}

    public void addHavingItem(HavingItem item) {
		if (item == null) {
			return;
		}
		this.havingItems.add(item);
	}

    public void addOrderByItem(OrderByItem item) {
		if (item == null) {
			return;
		}
		this.orderByItems.add(item);
	}

    public void setLimit(Limit limit) {
		this.limit = limit;
	}

    public void setDataSet(DataSet dataSet) {
		this.dataSet = dataSet;
	}

}
